<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			#div1{
				width:200px;
				height: 200px;
				background-color: #DC143C;
			}
		</style>
	</head>
	<!-- 4.实现DIV移动事件，采用监听器方式操作，可实现添加和清除监听器功能。 --> -->
	<body>
		<div id="div1" onmousemove="yidong()">
		</div>
		<button type="button" id="btnAdd" onclick="myaddlistener()" >为添加监听器</button>
		<button type="button" id="btnRemove" onclick="myremovelistener()" >清除监听器</button>
	</body>
	<script type="text/javascript">
		function yidong(){
			console.log('被点击了')
		}
		function myaddlistener(){
			document.getElementById('div1').addEventListener('click',yidong)
		}
		function myremovelistener(){
			document.getElementById('btn4').removeEventListener('click',yidong);
		}
	</script>
</html>
